﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Assertions;

namespace Nirvana
{
    public class WaitLoadAssetManifest : WaitLoadObjectAsync
    {

        public WaitLoadAssetManifest(AssetBundleManager mgr, string path, string bundlename, Type abtype) : base(mgr, path, bundlename, abtype)
        {

        }

        public override bool Load()
        {
            base.Load();
            if(base.Error != null)
            {
                this.AssetBundleMgr.Remove(this.AssetPath, false);
                return false;
            }

            if(this.AssetBundleRequest != null && this.AssetBundleRequest.isDone)
            {
                AssetBundleManifest mainfest = base.GetObject<AssetBundleManifest>();
                this.AssetBundleMgr.Remove(this.AssetPath, false);
                Assert.IsNotNull<AssetBundleManifest>(mainfest);
                this.AssetBundleMgr.Manifest = mainfest;
                return false;
            }
            return true;
        }
    }
}

